function to_thumb(id){
	window.location.href="../show_files_pic/ca_"+id+"type_1";
}

function hideOrShowDiv(id){
    var obj = document.getElementById(id);
    obj.style.display = (obj.style.display == 'inline' ? 'none' : 'inline');
}

function title_check(title_id, target_check){
    var sc = document.getElementById(title_id);
    var tc = document.getElementsByName(target_check);
    for(var i = 0; i<tc.length; i++){
        tc[i].checked = sc.checked
    }
}

function rows_check(title_id, cbs_name){
    var title_check = true;
    var cb_ids = [];
    var title_cb = document.getElementById(title_id);
    var row_cbs = document.getElementsByName(cbs_name);
    for(var i = 0; i < row_cbs.length; i++){
        if(row_cbs[i].checked){
            cb_ids.push(row_cbs[i].value)
        }else{
            title_check = false;
            title_cb.checked = false;
        }
    }
    if(title_check){
        title_cb.checked = true;
    }
    return cb_ids
}

function check_select_one(title_id, cbs_name,url){
	var check_id;
    if(document.getElementById(title_id).checked){
        alert("请选择其中的一条记录");
        return false;
    }
    var row_cbs = document.getElementsByName(cbs_name);
    var checked_number = 0;
    for(var i = 0; i < row_cbs.length; i++){
        if(row_cbs[i].checked){
        	check_id = row_cbs[i].value;
            checked_number += 1;
            if(checked_number > 1){
                alert("请选择其中的一条记录");
                return false;
            }
        }
    }
    if(checked_number == 0){
        alert("请选择其中的一条记录");
        return false;
    }
	if(url!=null){
		window.location.href=url+check_id;
	}
    return true;
}

function check_select(cbs_name,id,url){
    var row_cbs = document.getElementsByName(cbs_name);
    var checked_number = 0;
    for(var i = 0; i < row_cbs.length; i++){
        if(row_cbs[i].checked){
            checked_number += 1;
        }
    }
    if(checked_number < 1){
        alert("请选择要删除的记录");
        return false;
    }
	if(id!=null&&url!=null){
		form_submit(id,url);
	}
    return true;
}

function form_submit(id,url){
	var formObj = $('#'+id);
	formObj.attr('action',url);
}

